#!/bin/sh
# Check if bot is runing then exit otherwise restart
# in crontab
# 0,10,20,30,40,50 * * * * /home/karajia/karabot2/checkbot.sh


MYPATH=/home/karajia/karabot2/ 

PID=0

if test -r $MYPATH/data/karabot.pid; then
	PID=$(cat $MYPATH/data/karabot.pid)
fi

if [ 0 -ne $PID ]; then
	running=`ps --pid $PID | grep $PID |wc -l` 

	if [ $running -eq 1 ]; then
		exit 1 
	fi
fi

cd $MYPATH
./bot.sh & >/dev/null
